#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Author : Leiyh
# @File : pandas_tool.py
import xlwt


def write_excel(file_name,data_title,data_list,encoding='utf-8'):
    '''

    :param file_name: 文件路径地址
    :param data_title: excel第一行的标题栏
    :param data_list: 二维数据列表
    :param encoding:
    :return:
    '''
    # 创建workbook和sheet对象 注意Workbook的开头W要大写
    workbook = xlwt.Workbook(encoding=encoding)
    # 添加一个名为sheet1的表
    sheet1 = workbook.add_sheet('sheet1', cell_overwrite_ok=True)

    # 向表头写入数据
    for i in range(len(data_title)):
        sheet1.write(0, i, str(data_title[i]))

    # 向sheet写入数据
    for i in range(len(data_list)):
        for j in range(len(data_title)):
            sheet1.write(i + 1, j, str(data_list[i][j]))

    # 保存数据到‘Workbook2.xls’文件中
    workbook.save(file_name)
    print('创建execel完成！')

if __name__ == '__main__':
    # data = get_test_case("C:/softwareData/PycharmProjects/s00-wuling/documents/user/注册接口sign_up.xlsx")
    # print(data[0])
    # print(data[1])
    # write_excel("match_company.xls", ['news_id', '预期结果', '实际结果'],
    #             [['35942860', str(['', 'ICN5025197980', 1]), str(['', 'ICN5025197980', 1])]])
    write_excel("match_company.xls", ['news_id', '预期结果', '实际结果'],
                [['29543560', "['万云鹏', '吴震', '张志淳', '毛国华', '雷军']", "['雷军']"], ['29624072', "['陈建宁']", '[]'],
                 ['29714473', "['陈新港']", '[]'],
                 ['29729460', "['姜滨', '王希成', '陈学利', '陈学利', '陈学利']", "['姜滨', '王希成', '陈学利', '陈学利']"],
                 ['29933780', "['宁红涛', '张孝诚', '李南京', '熊海涛']",
                  "['宁红涛', '张孝诚', '李南京', '李南京', '沈肇章', '熊海涛', '熊海涛', '阮锋']"], ['30037838', "['黄健', '黄善兵']", '[]'],
                 ['30134950', "['高峰', '黄卿乐', '黄文佳']", '[]'], ['30155624', "['陆东福']", '[]'],
                 ['30240303', "['李宁', '林天福', '陈天桥']", "['林天福', '陈天桥']"],
                 ['30251305', "['冯育升', '朱少鹏', '杨光', '杨宝生', '杨愈静', '林伟雄', '林岳金', '罗海雄', '郑创佳', '陈东扬', '陈水挟']",
                  "['冯育升', '杨宝生', '陈水挟']"], ['30493048', "['梅群', '邸淑兵', '高振坤']", '[]'], ['30527812', "['夏文勇']", '[]'],
                 ['30703948', "['任彦堂', '史俊杰', '赵锐勇']", "['赵锐勇']"], ['30714488', "['章建伟', '袁旭', '陈俊']", "['袁旭']"],
                 ['30836175', "['张黎云']", '[]'], ['30870134', "['任正非']", "['任正非', '任正非']"],
                 ['30896602', "['黄巧灵']", '[]'], ['30943464', "['周启超']", '[]'], ['30986979', "['许世坛']", '[]'],
                 ['30995077', "['陈凯', '顾永德']", "['顾永德']"], ['31116429', "['胡玉良', '邹继新', '魏成文']", "['盛更红', '邹继新']"],
                 ['31515367', "['夏国新']", '[]'], ['31648890', "['刘永灼']", '[]'], ['31717740', "['丁世家']", '[]'],
                 ['31812414', "['王建超', '高登榜']", "['王建超']"], ['31840655', "['姜青松', '董凤亮']", '[]'],
                 ['31844329', "['李文全', '韦清文']", '[]'], ['31865304', "['王文彬']", '[]'],
                 ['31889812', "['Richard Zhou', '周家儒']", '[]'], ['32116062', "['周庆伍', '梁金辉']", '[]'],
                 ['32602635', "['周朝晖', '李英峰', '熊佩锦', '马彦钊']", "['周朝晖', '李英峰', '马彦钊']"], ['32797347', "['王存权']", '[]'],
                 ['32903319', "['金玉谟']", '[]'], ['33130262', "['任俐霞', '余东', '刘紫越', '李健', '杨平', '邱明']", '[]'],
                 ['33178109', "['凌云', '董建军']", "['宋钰锟', '董建军']"], ['33393755', "['孙洪斌']", '[]'],
                 ['33474624', "['俞宏福', '向文波', '杜毅刚', '杨笃志']", '[]'], ['33543031', "['杨寿海']", '[]'],
                 ['33681339', "['吴金应', '章丹玲', '顾振光']", "['周玉华', '张鑫', '王佳杰', '顾振光']"],
                 ['34154083', "['秦克景']", "['束海峰', '秦克景']"], ['34353168', "['陈晓东']", "['陈逊']"],
                 ['34354338', "['李彩云']", '[]'], ['34454097', "['罗友礼']", '[]'], ['34470648', "['潘彩红', '管延成']", '[]'],
                 ['34497686', "['章银凤', '陈滨']", "['陈滨']"], ['34746255', "['陈云伟', '陈富根']", '[]'],
                 ['35070273', "['张顼', '魏玉杰']", "['张顼']"],
                 ['35472838', "['刘希杰', '孙颖慧', '张英利', '朱岩', '李文军', '杨利民', '王亚杰', '王大可', '许新合']", '[]'],
                 ['35486462', "['沈健', '王艳涛', '章金富']", '[]'], ['35504950', "['曹江林']", '[]'],
                 ['35598577', "['郑建华', '黄瓯']", "['黄瓯']"], ['35713236', "['项乐宏']", '[]'], ['35748396', "['曹文明']", '[]'],
                 ['35919039', "['陈延行']", '[]'], ['36088097', "['柯鹏', '许家印', '许家印', '赵长龙']", "['许家印']"],
                 ['36347429', "['张旺华', '潘华']", "['潘华']"], ['37329941', "['季顺海', '蒋龄莉']", '[]'],
                 ['37415317', "['肖国强', '肖姣君']", "['李洪斌', '肖国强', '肖姣君']"], ['37668597', "['徐胜利', '肖义南', '黄晓亮']", '[]'],
                 ['37671387', "['冯彪', '徐胜利', '徐驰', '肖义南', '郭华平', '黄晓亮']", "['冯彪', '徐驰', '郭华平', '黄晓亮']"],
                 ['37700497', "['何超琼']", '[]'], ['37830927', "['杨书剑']", '[]'], ['37898790', "['乔欣', '张月明']", '[]'],
                 ['37937503', "['俞铮庆', '司文培']", '[]'], ['37958931', "['李海波', '李琴']", '[]'],
                 ['37992378', "['庞江华', '张剑洲', '汪东颖', '汪国有', '肖永平', '陈磊']", '[]'],
                 ['37993181', "['吴明武', '孙晓民', '房桂干', '陈菡']", "['吴明武', '房桂干', '陈菡', '魏雄文']"],
                 ['38021075', "['虞仁荣']", '[]'], ['38127473', "['姜佳立', '陈奕伦']", '[]'],
                 ['38142439', "['娄晓曦', '杜扬']", "['杜扬']"], ['38253348', "['朱楠', '葛玉君']", "['宋海丰', '朱楠', '葛玉君']"],
                 ['38329281', "['施一新', '沈彬']", '[]'], ['38425412', "['刘显峰']", "['马英姿']"],
                 ['39027951', "['单兵', '周勇', '林继阳', '王跃堂', '薛炳海', '虞虹']",
                  "['单兵', '周剑秋', '周勇', '林继阳', '王健英', '王跃堂', '薛炳海', '虞虹']"], ['39322132', "['沈生泉']", "['林柱英', '沈生泉']"],
                 ['39409984', "['马荣楷']", '[]'], ['39719444', "['刘强东', '刘炽平']", "['刘强东']"],
                 ['39840422', "['章小理']", '[]'], ['39862069', "['田晓楠']", "['杨仁贵', '田晓楠']"],
                 ['39971034', "['张铭文']", '[]'], ['40026354', "['陈忠其']", '[]'], ['40094610', "['岑钊雄']", '[]'],
                 ['40124066', "['侯启军', '戴厚良']", "['侯启军', '戴厚良', '马永生']"], ['40421440', "['庞晓龙']", "['徐海']"],
                 ['40432189', "['张翼飞', '王程']", "['王程']"], ['40438928', "['陈光珠', '陈炜俊']", "['文平', '陈光珠']"],
                 ['41093066', "['郑永刚']", '[]'], ['41188508', "['高怀雪', '黄文帜']", '[]'],
                 ['41240127', "['宋维平', '张立忠', '谈松林', '陈忠恒']", "['宋维平', '张立忠', '谈松林']"]])